package com.example.myutil;

//import java.nio.charset.Charset;

//import org.springframework.data.redis.serializer.RedisSerializer;
//import org.springframework.data.redis.serializer.SerializationException;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.serializer.SerializerFeature;

/**
 * spring-data-redids 使用的序列化与反序列化
 *
 *
 */
public class FastJson2JsonRedisSerializer {
//implements RedisSerializer<Object> {
//	
////	static{
////		//打开autotype功能 https://github.com/alibaba/fastjson/wiki/enable_autotype
////		ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
////	}
//
//    public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
//
//    public FastJson2JsonRedisSerializer(){
//    	super();
//    }
//    
//    @Override
//    public Object deserialize(byte[] bytes) throws SerializationException {
//        if (bytes == null || bytes.length <= 0) {
//            return null;
//        }
//        String str = new String(bytes, DEFAULT_CHARSET);
//
//        return JSON.parseObject(str,Object.class);
//    }
//
//    @Override
//	public byte[] serialize(Object t) throws SerializationException {
//		if (t == null) {
//            return new byte[0];
//        }
//		
//		String jsonStr = JSON.toJSONString(t,
//        		SerializerFeature.WriteClassName,
//        		SerializerFeature.SortField,
//        		SerializerFeature.WriteMapNullValue,
//        		SerializerFeature.WriteNullListAsEmpty,
//        		SerializerFeature.WriteNullBooleanAsFalse,
//        		SerializerFeature.SkipTransientField,
//        		SerializerFeature.WriteDateUseDateFormat
//        		);
//		
//        return jsonStr.getBytes(DEFAULT_CHARSET);
//	}



}